//
//  SearchBarViewController.m
//  B段项目
//
//  Created by dllo on 15/9/25.
//  Copyright (c) 2015年 昶博. All rights reserved.


#import "SearchBarViewController.h"
#import "PrefixHeader.pch"
#import "PrefixHeader.pch"
#import "SearchBarTableView.h"
#import "SearchDetailViewController.h"

@interface SearchBarViewController ()

@end

@implementation SearchBarViewController

- (void)viewWillAppear:(BOOL)animated
{
    SelfNavBar.hidden = YES;
    SelfTabBar.hidden = YES;
}


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = [UIColor whiteColor];

    
#pragma mark --顶部view
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight * 100 / 667)];
    view.backgroundColor = RGB(22, 188, 180);
    [self.view addSubview:view];
    
    
#pragma mark --添加返回按键
    UIButton *backButton = [UIButton buttonWithType:UIButtonTypeSystem];
    backButton.frame = CGRectMake(ScreenWidth * 10 / 375, ScreenHeight * 50 / 667, ScreenWidth * 60 / 375, ScreenWidth * 45 / 667);
    backButton.titleLabel.font = [UIFont systemFontOfSize:16];
    [backButton setTitle:@"返回" forState:UIControlStateNormal];
    [backButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [view addSubview:backButton];
    [backButton addTarget:self action:@selector(backButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
    
    [self tableViewSubviews];
    
    NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
    [center postNotificationName:@"passSearchUrl" object:self.urlStr];
    
    NSNotificationCenter *webCenter = [NSNotificationCenter defaultCenter];
    [webCenter addObserver:self selector:@selector(passWebUrl:) name:@"passWebUrl" object:nil];
    
}


- (void)passWebUrl:(NSNotification *)noti
{
    SearchDetailViewController *searchDetail = [[SearchDetailViewController alloc] init];
    searchDetail.webLink = noti.object;
    [self.navigationController pushViewController:searchDetail animated:NO];
}


- (void)tableViewSubviews
{
    SearchBarTableView *searchBarTableView = [[SearchBarTableView alloc] initWithFrame:CGRectMake(0, ScreenHeight * 100 / 667, ScreenWidth, ScreenHeight - ScreenHeight * 150 / 667) style:UITableViewStyleGrouped];
    [self.view addSubview:searchBarTableView];
}


#pragma mark --返回按键方法
- (void)backButtonClicked:(UIButton *)button
{
    [self.navigationController popToRootViewControllerAnimated:YES];
}







#pragma mark - Mmemory
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
